package com.xiaoyu.tool.entity.User;

import com.xiaoyu.tool.entity.common.AbstractEntity;
import com.xiaoyu.tool.enums.user.UserIntegralFromType;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.math.BigDecimal;

@Data
@Entity
@Table(name = "user_integral_detail")
@EqualsAndHashCode(callSuper = true)
public class UserIntegralDetail extends AbstractEntity {

    @Column
    private Long  orderId;

    @Column
    private Long userId;

    @Column
    private BigDecimal Integral = new BigDecimal(0);

    @Column
    @Enumerated(EnumType.STRING)
    private UserIntegralFromType userIntegralFromType = UserIntegralFromType.帮助朋友;

    @Column
    private String userProfitOrderNo;

    @Column
    private Boolean isTrue = true;

    public String intergralFromLabel(User user) {
        if (this.userIntegralFromType == UserIntegralFromType.帮助朋友) {
            return "帮助"+user.getNickName();
        } else if (this.userIntegralFromType == UserIntegralFromType.订单分润) {
            return "从" + user.getNickName() + "的订单中分的";
        } else {
            return this.userIntegralFromType.name();
        }
    }
    public String intergralFromLabel() {
        return this.userIntegralFromType.name();

    }


}
